#ifndef _XGBA_INPUT_H_
#define _XGBA_INPUT_H_

#include "xgba_p.h"

enum{
    xgba_input_shift_A      = 0x0,
    xgba_input_shift_B      = 0x1,
    xgba_input_shift_select = 0x2,
    xgba_input_shift_start  = 0x3,
    xgba_input_shift_right  = 0x4,
    xgba_input_shift_left   = 0x5,
    xgba_input_shift_up     = 0x6,
    xgba_input_shift_down   = 0x7,
    xgba_input_shift_R      = 0x8,
    xgba_input_shift_L      = 0x9,
};

typedef struct PACKED{
    uint16_t A      :1;
    uint16_t B      :1;
    uint16_t select :1;
    uint16_t start  :1;
    uint16_t right  :1;
    uint16_t left   :1;
    uint16_t up     :1;
    uint16_t down   :1;
    uint16_t R      :1;
    uint16_t L      :1;
}xgba_input_t;

typedef struct PACKED{
    uint16_t A      :1;
    uint16_t B      :1;
    uint16_t select :1;
    uint16_t start  :1;
    uint16_t right  :1;
    uint16_t left   :1;
    uint16_t up     :1;
    uint16_t down   :1;
    uint16_t R      :1;
    uint16_t L      :1;
    uint16_t nused:4;
    uint16_t irq_enable_flg:1;  //0禁用,1开启
    uint16_t irq_cond:1;    //0逻辑或,1逻辑与
}xgba_keycnt_t;

#define KEYINPUT ((xgba_input_t*)gba->io[0x130])
#define KEYCNT  ((xgba_keycnt_t*)gba->io[0x132])

#define xgba_setkey(gba,value) \
    *((uint16_t*)&gba->io[0x130]) = ((~value)&0x3ff);

#endif
